package utils

import (
	"apitestAfterGo/common"
	"fmt"
	"github.com/go-playground/validator/v10"
)

func WrapValidationErrors(errs validator.ValidationErrors) []common.ValidationError {
	validationErrors := make([]common.ValidationError, 0, len(errs))
	for _, validationErr := range errs {
		validationErrors = append(validationErrors, common.ValidationError{
			ActualTag: validationErr.ActualTag(),
			Namespace: validationErr.Namespace(),
			Kind:      validationErr.Kind().String(),
			Type:      validationErr.Type().String(),
			Value:     fmt.Sprintf("%v", validationErr.Value()),
			Param:     validationErr.Param(),
		})
	}
	return validationErrors
}
